import { useCallback, useState } from 'react'
import { useHistory } from 'react-router-dom'

export const useNavigateHook = () => {
  const history = useHistory()
  const back = useCallback(() => {
    history.go(-1)
  }, [])
  const backHome = useCallback(() => {
    history.push('/home')
  }, [])
  const backLogin = useCallback(() => {
    history.push('/login')
  }, [])
  return { back, backHome, backLogin }
}

export const useDrawer = () => {
  const [open, setOpen] = useState(false)
  const [foodId, setFoodId] = useState(0)
  const handleOnChange = useCallback((id: number) => {
    setFoodId(id)
    setOpen(true)
  }, [])
  return {open, foodId, toggole: () => setOpen(!open), handleOnChange}
}
